package so.wy.servicecenter.businessbed.manager.fm;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import so.wy.servicecenter.base.frame.manager.AbstractManager;
import so.wy.servicecenter.businessbed.dao.enums.StatusDeviceRunEnum;
import so.wy.servicecenter.businessbed.dao.rdb.device.DeviceDAO;
import so.wy.servicecenter.businessbed.dao.rdb.device.DeviceDO;

@Service
@Scope("prototype")
public class DeviceFManager extends AbstractManager {
    @Autowired
    private DeviceDAO deviceDAO;

    //校验床是否存在 若存在则返回床信息
    public DeviceDO getDeviceInfo(String deviceSerial) {
        return deviceDAO.selectOne(new LambdaQueryWrapper<DeviceDO>()
                .eq(DeviceDO::getDeviceSerial, deviceSerial));
    }

    //更新设备状态
    public void updateDeviceRunStatus(Long deviceId, StatusDeviceRunEnum statusDeviceRun){
        DeviceDO upDO = new DeviceDO();
        upDO.setDeviceId(deviceId);
        upDO.setDeviceStatus(statusDeviceRun.getCode());
        deviceDAO.updateById(upDO);
    }


}
